import React, { PureComponent, Fragment } from "react";
import {
  Form,
  Input,
  Select,
  Modal,
  Radio
} from "antd";


const FormItem = Form.Item;
const { TextArea } = Input;
const { Option } = Select;

//更新和新增用户信息   modalVisible

@Form.create()
class checkCompany extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {};

    this.formLayout = {
      labelCol: { span: 7 },
      wrapperCol: { span: 13 }
    };
  }

  // 表单
  renderContent = () => {
    const { form, values } = this.props;
    const arr = ["通过", "驳回"];
    let children = [];
    for (let i = 0; i < arr.length; i++) {
      children.push(<Option key={i + 1}>{arr[i]}</Option>);
    }
    return [
      <FormItem key="type" {...this.formLayout} label="审核状态">
        {form.getFieldDecorator("type", {
          rules: [{ required: true, message: "请输入审核状态！" }]
        })(
          <Select
            style={{ width: "100%" }}
            placeholder="请输选择状态">
            {children}
          </Select>
        )}
      </FormItem>,
      form.getFieldValue('type') === '2' ? <FormItem key="reason" {...this.formLayout} label="说明">
        {form.getFieldDecorator('reason', {
          rules: [{ required: true, message: '请输入驳回原因！', min: 5 }],
        })(<TextArea rows={4} placeholder="请输入至少五个字符"/>)}
      </FormItem> : ''
    ];
  };

  //弹窗
  render() {
    const { visibleCheck, handleCheck } = this.props;

    //完成
    const handleNext = () => {
      const { form, passCheck } = this.props;

      form.validateFields((err, fieldsValue) => {
        if (err) return;
        let formVals = { ...fieldsValue };
        formVals.type = Number(formVals.type);
        passCheck(false, formVals);
      });
    };
    return (
      <Modal
        width={640}
        bodyStyle={{ padding: "32px 40px 48px" }}
        destroyOnClose
        title='审核'
        visible={visibleCheck}
        onOk={handleNext}
        onCancel={() => handleCheck(false, [])}
      >
        {this.renderContent()}
      </Modal>
    );
  }
}

export default checkCompany;
